Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow specifying fluent message attributes directly and via tera #4

Merged
merged 5 commits into from
Jul 1, 2024

Conversation

jreppnow
Copy link
Collaborator

@jreppnow jreppnow commented Jul 1, 2024

No description provided.

src/fluent.rs Outdated Show resolved Hide resolved
src/fluent.rs Show resolved Hide resolved
src/fluent.rs Show resolved Hide resolved
src/tera.rs Outdated Show resolved Hide resolved
Copy link
Owner

@tronicboy1 tronicboy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very very cool PR! I'm excited to use this 🙂

Comment on lines +269 to +296
fn compiles_with_borrowed_string() {
let mut loc = Localizer::new();
loc.add_bundle(ENGLISH, &[MAIN, SUB]).unwrap();

loc.format_message(&ENGLISH, &"test-key-a".to_owned(), None);
}

#[test]
fn use_attributes() {
let mut loc = Localizer::new();
loc.add_bundle(ENGLISH, &[MAIN, SUB]).unwrap();

let message = loc
.format_message(
&ENGLISH,
&MessageAttribute {
key: "attribute-test",
attribute: "attribute_a",
},
None,
)
.expect("formatting succeeds");

assert_eq!("Hello", message)
}

#[test]
fn not_existing_attribute() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, also a good way to see how to use them in the wild 🦘👍.

@jreppnow jreppnow merged commit 056807a into tronicboy1:master Jul 1, 2024
1 check passed
@jreppnow jreppnow deleted the feat/reppnj/attributes branch July 1, 2024 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants